//
// 移动零
// Created by madison on 2022/9/5.
//

#include "vector"
#include "unordered_set"

using namespace std;

class Solution {
public:
    // 方法一：双指针
    void moveZeroes(vector<int> &nums) {
        int n = nums.size(), left = 0, right = 0;
        while (right < n) {
            if (nums[right]) {
                swap(nums[left], nums[right]);
                left++;
            }
            right++;
        }
    }
};

int main() {
    Solution solution;
    vector<int> nums = {0, 1, 0, 3, 12};
    solution.moveZeroes(nums);
    for (auto &num: nums) {
        printf("%d\t", num);
    }
    return 0;
}